package com.zls.zpedia;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.zls.commonutil.Texty;
import com.zls.commonutil.component.BaseActivity;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class SplashActivity extends BaseActivity {

    @Bind(R.id.iv)
    ImageView iv;

    private int[] srcs = {R.mipmap.enjoy_your_life, R.mipmap.star_sky, R.mipmap.world_is_great};
    private int index = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);

        iv.setImageResource(srcs[0]);

        loadImage();

    }

    private void loadImage() {
        iv.postDelayed(new Runnable() {
            @Override
            public void run() {
                index ++;

                if(index >= srcs.length){
                    finish();
                    return;
                }

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        iv.setImageResource(srcs[index]);
                        loadImage();
                    }
                });
            }
        }, 1000);
    }

}
